<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
$return['account']=$_SESSION['account'];
$return['extradata']=array();
if($_RQ['op']=='get'){
	$quicks=pdo_getall('core_user_quick',array('uid'=>$_SESSION['uid']),array('id','action','op','plugin','title','query','html'));
	if($quicks){
		foreach($quicks as &$quick){
			$quick=array('id'=>$quick['id'],'title'=>$quick['title'],'url'=>array('action'=>$quick['action'],'op'=>$quick['op'],'plugin'=>$quick['plugin'],'query'=>$quick['query'],'title'=>$quick['title'],'html'=>$quick['html']));
		}
	}
	//数据统计
	$access=array();
	$access['wechat_day']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>2,'createtime >'=>strtotime(date('ymd'))));
	$access['wxapp_day']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>1,'createtime >'=>strtotime(date('ymd'))));
	$access['mobile_day']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>3,'createtime >'=>strtotime(date('ymd'))));
	$access['pc_day']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>4,'createtime >'=>strtotime(date('ymd'))));
	$access['app_day']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>5,'createtime >'=>strtotime(date('ymd'))));
	$access['all_day']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'createtime >'=>strtotime(date('ymd'))));
	$access['wechat_all']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>2));
	$access['wxapp_all']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>1));
	$access['mobile_all']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>3));
	$access['pc_all']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>4));
	$access['app_all']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>5));
	$access['all_all']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2));
	$wechat=array();
	//当日关注
	$wechat['focus_day']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>2,'follow'=>1,'updatetime >'=>strtotime(date('ymd'))));
	//总关注
	$wechat['focus_all']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>2,'follow'=>1));
	//当日取消关注
	$wechat['unfocus_day']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>2,'follow'=>0,'updatetime >'=>strtotime(date('ymd'))));
	//总取消关注
	$wechat['unfocus_all']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>2,'follow'=>0));
	//当日新增粉丝
	$wechat['fans_day']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>2,'createtime >'=>strtotime(date('ymd'))));
	//总粉丝
	$wechat['fans_all']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>2));
	//当日贡献会员
	$wechat['member_day']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>2,'createtime >'=>strtotime(date('ymd'))));
	//总贡献会员
	$wechat['member_all']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>2));
	$wxapp=array();
	$wxapp['access_day']=$access['wxapp_day'];
	$wxapp['access_mounth']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>1,'createtime >'=>strtotime(date('ym'))));
	$wxapp['access_all']=$access['wxapp_all'];
	//当日新增粉丝
	$wxapp['fans_day']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>1,'createtime >'=>strtotime(date('ymd'))));
	//总粉丝
	$wxapp['fans_all']=pdo_count('core_fans',array('uniacid'=>$_SESSION['uniacid'],'type'=>1));
	//当日贡献会员
	$wxapp['member_day']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>1,'createtime >'=>strtotime(date('ymd'))));
	//总贡献会员
	$wxapp['member_all']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>1));
	//手机端数据
	$mobile=array();
	//当月访问
	$mobile['access_mounth']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>3,'createtime >'=>strtotime(date('ym'))));
	//总访问
	$mobile['access_all']=$access['mobile_all'];
	//当日贡献会员
	$mobile['member_day']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>3,'createtime >'=>strtotime(date('ymd'))));
	//总贡献会员
	$mobile['member_all']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>3));
	//app端数据
	$app=array();
	//当月访问
	$app['access_mounth']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>5,'createtime >'=>strtotime(date('ym'))));
	//总访问
	$app['access_all']=$access['app_all'];
	//当日贡献会员
	$app['member_day']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>5,'createtime >'=>strtotime(date('ymd'))));
	//总贡献会员
	$app['member_all']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>5));
	//pc端数据
	$pc=array();
	//当月访问
	$pc['access_mounth']=pdo_count('core_access_log',array('uniacid'=>$_SESSION['uniacid'],'this'=>2,'os'=>4,'createtime >'=>strtotime(date('ym'))));
	//总访问
	$pc['access_all']=$access['pc_all'];
	//当日贡献会员
	$pc['member_day']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>4,'createtime >'=>strtotime(date('ymd'))));
	//总贡献会员
	$pc['member_all']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'from_os'=>4));
	$return['htmls']=array(
		array('type'=>'list_menu','title'=>'快捷操作','menus'=>$quicks,'del'=>true),
		array('type'=>'data','one_num'=>2,'title'=>'站点今日/总访问数据指标','datas'=>array(
			array('title'=>'公众号数据','num'=>2,'data'=>array($access['wechat_day'],$access['wechat_all'])),
			array('title'=>'小程序数据','num'=>2,'data'=>array($access['wxapp_day'],$access['wxapp_all'])),
			array('title'=>'手机端数据','num'=>2,'data'=>array($access['mobile_day'],$access['mobile_all'])),
			array('title'=>'PC端数据','num'=>2,'data'=>array($access['pc_day'],$access['pc_all'])),
			array('title'=>'APP端数据','num'=>2,'data'=>array($access['app_day'],$access['app_all'])),
			array('title'=>'总访问量','num'=>2,'data'=>array($access['all_day'],$access['all_all'])),
		)),
		array('type'=>'data','num'=>6,'one_num'=>3,'title'=>'公众号数据指标（仅统计主公众号）','datas'=>array(
			array('title'=>'今日/总关注','num'=>2,'data'=>array($wechat['focus_day'],$wechat['focus_all'])),
			array('title'=>'小程序数据','num'=>2,'data'=>array($wechat['unfocus_day'],$wechat['unfocus_all'])),
			array('title'=>'手机端数据','num'=>2,'data'=>array($wechat['fans_day'],$wechat['fans_all'])),
			array('title'=>'PC端数据','num'=>2,'data'=>array($wechat['member_day'],$wechat['member_all'])),
		)),
		array('type'=>'data','num'=>6,'one_num'=>3,'title'=>'小程序数据指标（所有小程序之和）','datas'=>array(
			array('title'=>'今日/总访问量','num'=>2,'data'=>array($wxapp['access_day'],$wxapp['access_all'])),
			array('title'=>'当月访问量','num'=>1,'data'=>$wxapp['access_mounth']),
			array('title'=>'今日新增/总粉丝数','num'=>2,'data'=>array($wxapp['fans_day'],$wxapp['fans_all'])),
			array('title'=>'PC端数据','num'=>2,'data'=>array($wxapp['member_day'],$wxapp['member_all'])),
		)),
		array('type'=>'data','num'=>6,'one_num'=>3,'title'=>'手机端（除微信端、小程序端外）数据指标','datas'=>array(
			array('title'=>'今日/总访问量','num'=>1,'data'=>$mobile['access_mounth']),
			array('title'=>'当月访问量','num'=>1,'data'=>$mobile['access_all']),
			array('title'=>'今日新增/总粉丝数','num'=>1,'data'=>$mobile['member_day']),
			array('title'=>'PC端数据','num'=>1,'data'=>$mobile['member_all']),
		)),
		array('type'=>'data','num'=>6,'one_num'=>3,'title'=>'PC端数据指标','datas'=>array(
			array('title'=>'今日/总访问量','num'=>1,'data'=>$pc['access_mounth']),
			array('title'=>'当月访问量','num'=>1,'data'=>$pc['access_all']),
			array('title'=>'今日新增/总粉丝数','num'=>1,'data'=>$pc['member_day']),
			array('title'=>'PC端数据','num'=>1,'data'=>$pc['member_all']),
		)),
		array('type'=>'data','num'=>6,'one_num'=>3,'title'=>'APP端数据指标','datas'=>array(
			array('title'=>'今日/总访问量','num'=>1,'data'=>$app['access_mounth']),
			array('title'=>'当月访问量','num'=>1,'data'=>$app['access_all']),
			array('title'=>'今日新增/总粉丝数','num'=>1,'data'=>$app['member_day']),
			array('title'=>'PC端数据','num'=>1,'data'=>$app['member_all']),
		)),
	);
	exi($return);
}
if($_RQ['op']=='set'){
	$postdata=get_postdata();
	$data=array(
		'uid'=>$_SESSION['uid'],
		'action'=>trim($postdata['action']),
		'plugin'=>trim($postdata['plugin']),
		'op'=>trim($postdata['op']),
		'query'=>trim($postdata['query']),
		'title'=>trim($postdata['title']),
		'html'=>trim($postdata['html'])
	);
	pdo_insert('core_user_quick',$data);
	exi('添加成功！该快捷方式将会显示在欢迎界面！');
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('core_user_quick',array('id'=>$id,'uid'=>$_SESSION['uid']));
	}
	exi('删除成功！');
}
?>